{% extends "base.html" %}

{% block title %}成绩管理 - 教育管理系统{% endblock %}

{% block content %}
<div class="container-fluid">
    <h1 class="text-center mb-4">成绩管理</h1>
    
    <div class="row">
        <div class="col-md-12 mb-4">
            <div class="card shadow">
                <div class="card-header bg-primary text-white">
                    <h5 class="card-title mb-0">添加/更新成绩</h5>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('dashboard.manage_scores') }}">
                        <div class="row">
                            <div class="col-md-3 mb-3">
                                <label for="student_id" class="form-label">学生</label>
                                <select class="form-select" id="student_id" name="student_id" required>
                                    <option value="" selected disabled>选择学生</option>
                                    {% for student in students %}
                                    <option value="{{ student.id }}">{{ student.name }} ({{ student.grade }})</option>
                                    {% endfor %}
                                </select>
                            </div>
                            <div class="col-md-3 mb-3">
                                <label for="course_id" class="form-label">课程</label>
                                <select class="form-select" id="course_id" name="course_id" required>
                                    <option value="" selected disabled>选择课程</option>
                                    {% for course in courses %}
                                    <option value="{{ course.id }}">{{ course.name }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                            <div class="col-md-2 mb-3">
                                <label for="test_number" class="form-label">考试次数</label>
                                <select class="form-select" id="test_number" name="test_number" required>
                                    <option value="" selected disabled>选择次数</option>
                                    {% for i in range(1, 11) %}
                                    <option value="{{ i }}">第{{ i }}次</option>
                                    {% endfor %}
                                </select>
                            </div>
                            <div class="col-md-2 mb-3">
                                <label for="score_value" class="form-label">分数</label>
                                <input type="number" class="form-control" id="score_value" name="score_value" min="0" max="100" step="0.1" required>
                            </div>
                            <div class="col-md-2 mb-3 d-flex align-items-end">
                                <button type="submit" class="btn btn-primary w-100">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card shadow">
                <div class="card-header bg-info text-white">
                    <h5 class="card-title mb-0">成绩记录</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-hover">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>学生</th>
                                    <th>课程</th>
                                    <th>分数</th>
                                    <th>考试次数</th>
                                    <th>考试日期</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for score_item in scores %}
                                <tr>
                                    <td>{{ score_item.Score.id }}</td>
                                    <td>{{ score_item.student_name }}</td>
                                    <td>{{ score_item.course_name }}</td>
                                    <td>{{ score_item.Score.score_value }}</td>
                                    <td>第{{ score_item.Score.test_number }}次</td>
                                    <td>{{ score_item.Score.test_date.strftime('%Y-%m-%d %H:%M') }}</td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 